<%@ page import="cn.io0288.blog2.model.Article" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
    Article a = (Article) request.getAttribute("article");
%>

<main class="mt-5">
    <div class="container">
        <form class="col-12" method="POST" action="<c:out value="${requestScope.action}" default="/insert"/>">
            <div class="form-group" hidden>
                <input type="text" class="form-control" id="exampleInputAid" name="aid"
                       value="<%= a.aid %>" hidden>
            </div>
            <div class="form-group row">
                <div class="col-4">
                    <label>文章Aid</label>
                    <input type="text" class="form-control"
                           value="<%= a.aid %>" placeholder="自动增长" disabled>
                </div>
                <div class="col-4">
                    <label>分类Cid</label>
                    <input type="text" class="form-control" name="cid"
                           value="<%= a.cid %>" placeholder="默认:1" required>
                </div>
                <div class="col-4">
                    <label>用户Uid</label>
                    <input type="text" class="form-control" name="uid"
                           value="<%= a.uid %>" placeholder="默认:1" disabled>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-6">
                    <label for="exampleInputimg1">展示图片</label>
                    <input type="text" class="form-control" id="exampleInputimg1" name="img"
                           value="<%= a.img %>" placeholder="url地址或相对地址" required>
                </div>
                <div class="col-6">
                    <label for="exampleInputimgalt1">展示图片Alt</label>
                    <input type="text" class="form-control" id="exampleInputimgalt1" name="img_alt"
                           value="<%= a.img_alt %>" placeholder="文本" required>
                </div>
            </div>
            <div class="form-group row col-12">
                <label for="exampleInputTitle1">标题</label>
                <input type="text" class="form-control" id="exampleInputTitle1" name="title1"
                       value="<%= a.title %>" required>
            </div>
            <div class="form-group row col-12">
                <label for="exampleInputTitle2">副标题</label>
                <input type="text" class="form-control" id="exampleInputTitle2" name="title2"
                       value="<%= a.title2 %>" required>
            </div>
            <div class="form-group row col-12">
                <label for="exampleTextareaContent1">内容</label><br>
                <textarea class="form-control" name="content" id="exampleTextareaContent1" cols="30" rows="10"
                          required><%= a.content %></textarea>
                <small id="content" class="form-text text-muted">支持MD语法.</small>
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-primary">保存并提交</button>
                <button type="button" onclick="location.replace(document.referrer);"
                        class="btn btn-warning text-light">返回
                </button>
                <a class="btn btn-outline-danger float-right" href="/adminDelete/<%= a.aid %>">删除</a>
            </div>
        </form>
    </div>
</main>